public class Morale {
	private float morale;
	private int oldPop;

	public Morale(int pop) {
		morale = 0;
		oldPop = pop;
	}
	
	public Morale() {
		morale = 0;
		oldPop = 0;
	}
	
	public void updatePop(int pop) {
		oldPop = pop;
	}

	// depends much on update interval
	public void calculateMorale(int curPop) {
		if (morale > 0)
			morale -= ((oldPop - curPop) / 100);
		else
			morale = 0;
		oldPop = curPop;
	}

	// depends on update interval. once every 2 second, it takes 10 sec to loose
	// 1 morale level
	public void timeDrop() {
		morale -= 0.1;
	}

	// If loss of house/armory
	public void remove(float value) {
		if (morale > 0)
			morale -= value;
	}

	// If armory or upgrade to lvl > 3
	public void add(float value) {
		if (morale < 6)
			morale += value;
	}

	// designed to only return whole numbers
	public byte getMorale() {
		if (morale > 0)
			return (byte) morale;
		else
			return 0;
	}
}
